home *** CD-ROM | disk | FTP | other *** search
- Path: pegasus.montclair.edu!harmon
- From: harmon@pegasus.montclair.edu (Derek Harmon)
- Newsgroups: comp.lang.c
- Subject: Re: simple code, argc, argv, strcmp()
- Date: 1 Feb 1996 13:08:37 -0500
- Organization: Montclair State University
- Message-ID: <harmon.823197381@pegasus.montclair.edu>
- References: <11f7cc$17261a.3b3@daprez>
- NNTP-Posting-Host: pegasus.montclair.edu
- Keywords: strcmp encode decode argc argv
- X-Newsreader: NN version 6.5.0 #68 (NOV)
-
- otisg@panther.middlebury.edu (Otis Gospodnetic) writes:
- > if (!strcmp(argv[1],"-d") || !strcmp(argv[1],"-e")) {
- > Usage();
- > }
-
- This is where your troubles lie. Let's think for a second, if argv[1]
- is "-d", then the first clause is false. BUT, if argv[1] is "-d" then it
- cannot also be "-e", so the second clause is true, and Usage() is called.
- On the other hand, if argv[1] is "-e", then the second clause is false.
- Unfortunately, argv[1] is then surely not "-d", and the first clause is true.
-
- Therefore, I would suggest that you only call Usage() when argv[1] is
- not "-d" AND not "-e":
-
- : if (!strcmp(argv[1],"-d") && !strcmp(argv[1],"-e")) {
-
- -- Stone
- --
- ... Your program is sick! Shoot it and put it out of its memory.
-
-
-
-